package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Daily;
import cn.wolfcode.trip.base.domain.Store;
import cn.wolfcode.trip.base.mapper.StoreMapper;
import cn.wolfcode.trip.base.query.GrogshopQuery;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.StoreQuery;
import cn.wolfcode.trip.base.service.IStoreService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StoreServiceImpl implements IStoreService {
    @Autowired
    private StoreMapper storeMapper;


    public PageInfo query(StoreQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), true, false, null);
        List<Store> list = storeMapper.selectForList(qo);
        return new PageInfo<>(list);
    }

    @Override
    public void updateShelves(Store store) {
        storeMapper.updateShelves(store);
    }

    @Override
    public void saveOrUpdate(Store store) {
        if (store.getId()==null){
            storeMapper.insert(store);
        }else {
            storeMapper.updateByPrimaryKey(store);

        }
    }

    @Override
    public Store selectById(Long id) {

        return storeMapper.selectByPrimaryKey(id);
    }
}
